package com.ijiuchuang.jc_localization.presenter;

import android.content.Context;

import com.ijiuchuang.jc_localization.bean.bmob.Banner;
import com.ijiuchuang.jc_localization.bean.api.Keji;
import com.ijiuchuang.jc_localization.contract.HomeContract;
import com.ijiuchuang.jc_localization.model.HomeModel;

import java.util.List;

import rx.functions.Action1;

/**
 * Created by Veev on 2016/6/18
 *
 * @link 384506557@qq.com
 */
public class HomePresenter implements HomeContract.Presenter {

    private Context mContext;
    private HomeContract.View mView;
    private HomeContract.Model mModel;

    public HomePresenter(Context mContext, HomeContract.View mView) {
        this.mContext = mContext;
        this.mView = mView;
        mModel = new HomeModel();

        mView.setPresenter(this);
    }

    @Override
    public void start() {
        // start here
        mModel.getBannersFromNet(new Action1<List<Banner>>() {
            @Override
            public void call(List<Banner> banners) {
                mView.setBanners(banners);
            }
        });

        mModel.getKeji(new Action1<Keji>() {
            @Override
            public void call(Keji keji) {
                mView.setTrends(keji);
            }
        });
    }
}